//
//  MeViewController.m
//  LZMusicPlayer
//
//  Created by wulanzhou on 2016/10/31.
//  Copyright © 2016年 wulanzhou. All rights reserved.
//

#import "MeViewController.h"

@interface MeViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) UITableView *meTable;
@property (nonatomic,strong) NSArray *dataSource;
@end

@implementation MeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title =@"我";
    [self.view addSubview:self.meTable];
    
    // Do any additional setup after loading the view.
}

- (UITableView *)meTable{

    if (!_meTable) {
        
        _meTable = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
        _meTable.dataSource = self;
        _meTable.delegate = self;
        _meTable.rowHeight = 50.0f;
        
        UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 0)];
        _meTable.tableFooterView = footerView;
    }
    return _meTable;
}

- (NSArray *)dataSource{

    if (!_dataSource) {
        
        NSMutableArray *source = [NSMutableArray arrayWithCapacity:0];
        [source addObject:@"本地音乐"];
        [source addObject:@"最近播放"];
        [source addObject:@"我的收藏"];
        _dataSource = source;
        
    }
    return _dataSource;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark -Table source & delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [self.dataSource count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *cellIdentifier = @"meCellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.textLabel.text = self.dataSource[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end
